<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Online tools for developers</title>
    <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css"/>
    <script src="wasm_exec.js"></script>
<style>
pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
</style>
</head>
<body>
<script>
    (async function loadAndRunGoWasm() {
        const go = new Go();
        const response = await fetch("main.wasm");
        const buffer = await response.arrayBuffer();
        const result = await WebAssembly.instantiate(buffer, go.importObject);
        go.run(result.instance)
    })()

    function doConvert(action) {
        const data = document.getElementById("data").value
        if (data == "") {
            return
        }
        let result
        switch(action){
            case 'jsonFormat':
                result = window.formatJSON(data)
                break
            case 'base64Encode':
                result = window.base64Encode(data)
                break
            case 'base64Decode':
                result = window.base64Decode(data)
                break
        }
        document.getElementById("output").innerText = result
    }

    function generateSecret() {
        const length = document.getElementById('length').value
        const capital = document.getElementById('password-capital').checked
        const special = document.getElementById('password-special').checked
        const number = document.getElementById('password-number').checked

        const result = window.generatePassword(Number(length), capital, special, number)
        document.getElementById("password-result").innerText = result
    }
</script>
<a class="github-fork-ribbon" target="_blank"
   href="https://github.com/linuxsuren/tools"
   data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
<button type="button" onclick="doConvert('jsonFormat')">JSONFormat</button>
<button type="button" onclick="doConvert('base64Encode')">Base64Encode</button>
<button type="button" onclick="doConvert('base64Decode')">Base64Decode</button>
<br/>
<textarea id="data" style="margin: 0px;width: 100%;height: 100px;">
{"tips":"Hello great developers!"}
</textarea>
<pre id="output"></pre>

Generate Password:
Length: <input id="length" value="8" type="text"/>
Capital Letter: <input id="password-capital" type="checkbox" checked=""/>
Special: <input id="password-special" type="checkbox" checked=""/>
Number: <input id="password-number" type="checkbox" checked=""/>
<button type="button" onclick="generateSecret()">Generate</button>
<br/>
<textarea id="password-result"></textarea>

</body>
<div style="bottom: 5px; position: absolute;">
    <a href="https://linuxsuren.github.io/audacity-label-plugin" target="_blank">Audacity</a>
    <div>
        <img src="https://profile-counter.glitch.me/{linuxsuren-tools}/count.svg"/>
    </div>
    <a href="https://linuxsuren.github.io/tools/video.html" target="_blank">Video</a>
</div>

</html>
